load("data-raw/ListOfAllHeatwaves.Rdata")
hw=data.frame(all.hws)
colnames(hw)[28]<="mean.temp.1"
## [1] FALSE
y1=hw$Estimate
y2=hw$post.estimate
## Test individual variables and response
library(splines)
library(ggplot2)
library(xtable)
xvar1 <- c("mean.temp","max.temp","min.temp","length","start.doy","days.above.80","days.above.85","days.above.90","days.above.95","days.above.99th", "days.above.99.5th","mean.temp.quantile","max.temp.quantile","min.temp.quantile","pop100","Ppoverty","Ppoverty75p","Purban","P75p","pop.density", "mean.temp.1","mean.summer.temp")
xvar2 <- c("start.month","first.in.season")
for (x in xvar1){
print(x)
my.x <-hw[,x]
my.mod1 <- glm(y1~my.x)
print(summary(my.mod1))
#plot(my.x, y1, main = x, xlab = x)
to_plot <- data.frame(my.x, y1, y2)
a <- ggplot(to_plot, aes(x = my.x, y = y1)) + geom_point(alpha = 0.3) + geom_smooth() + xlab(x) + ggtitle(x)
print(a)
my.mod2 <- glm(y2~my.x)
print(summary(my.mod2))
#plot(my.x, y2, main = x, xlab = x)
b <- ggplot(to_plot, aes(x = my.x, y = y2)) + geom_point() + geom_smooth(span = 0.3) + xlab(x) + ggtitle(x)
print(b)
}
## [1] "mean.temp"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.96991 -0.09920 0.01667 0.11567 0.77929
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.1478065 0.0624267 2.368 0.0180 *
## my.x -0.0014253 0.0007355 -1.938 0.0527 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0381296)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 113.55 on 2978 degrees of freedom
## AIC: -1274.1
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10311 -0.01862 -0.00204 0.01550 0.52075
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0806886 0.0097375 8.286 <2e-16 ***
## my.x -0.0002932 0.0001147 -2.556 0.0106 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.000927726)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7628 on 2978 degrees of freedom
## AIC: -12348
##
## Number of Fisher Scoring iterations: 2

## [1] "max.temp"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.97249 -0.10007 0.01587 0.11584 0.77671
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0749358 0.0621628 1.205 0.228
## my.x -0.0005580 0.0007229 -0.772 0.440
##
## (Dispersion parameter for gaussian family taken to be 0.03817004)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 113.67 on 2978 degrees of freedom
## AIC: -1270.9
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10346 -0.01848 -0.00211 0.01537 0.52073
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0664215 0.0096999 6.848 9.08e-12 ***
## my.x -0.0001232 0.0001128 -1.092 0.275
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009293885)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7677 on 2978 degrees of freedom
## AIC: -12342
##
## Number of Fisher Scoring iterations: 2

## [1] "min.temp"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.96554 -0.09888 0.01666 0.11461 0.78366
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.2190875 0.0604579 3.624 0.000295 ***
## my.x -0.0022948 0.0007211 -3.182 0.001477 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0380483)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 113.31 on 2978 degrees of freedom
## AIC: -1280.4
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10369 -0.01859 -0.00205 0.01566 0.51964
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0952239 0.0094232 10.105 < 2e-16 ***
## my.x -0.0004706 0.0001124 -4.187 2.91e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009243208)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7526 on 2978 degrees of freedom
## AIC: -12359
##
## Number of Fisher Scoring iterations: 2

## [1] "length"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.96700 -0.10079 0.01393 0.11688 0.78220
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.011196 0.007237 1.547 0.1219
## my.x 0.004850 0.001926 2.518 0.0119 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.03809659)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 113.45 on 2978 degrees of freedom
## AIC: -1276.7
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10372 -0.01868 -0.00217 0.01537 0.51997
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.585e-02 1.131e-03 49.405 <2e-16 ***
## my.x -3.815e-06 3.009e-04 -0.013 0.99
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009297609)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7688 on 2978 degrees of freedom
## AIC: -12341
##
## Number of Fisher Scoring iterations: 2

## [1] "start.doy"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.93860 -0.09699 0.01431 0.11610 0.77124
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.1511477 0.0284908 5.305 1.21e-07 ***
## my.x -0.0006055 0.0001379 -4.391 1.17e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.03793211)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 112.96 on 2978 degrees of freedom
## AIC: -1289.6
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10113 -0.01846 -0.00246 0.01543 0.51844
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.003e-02 4.438e-03 18.033 < 2e-16 ***
## my.x -1.180e-04 2.148e-05 -5.494 4.27e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009204324)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7410 on 2978 degrees of freedom
## AIC: -12371
##
## Number of Fisher Scoring iterations: 2

## [1] "days.above.80"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.97193 -0.10025 0.01435 0.11664 0.77727
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.022706 0.005949 3.817 0.000138 ***
## my.x 0.001561 0.001712 0.911 0.362194
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.03816703)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 113.66 on 2978 degrees of freedom
## AIC: -1271.2
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10287 -0.01865 -0.00208 0.01544 0.52055
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0565759 0.0009283 60.946 <2e-16 ***
## my.x -0.0002644 0.0002672 -0.989 0.323
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009294554)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7679 on 2978 degrees of freedom
## AIC: -12342
##
## Number of Fisher Scoring iterations: 2

## [1] "days.above.85"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.97291 -0.09997 0.01555 0.11553 0.77629
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0281486 0.0045344 6.208 6.12e-10 ***
## my.x -0.0006684 0.0016729 -0.400 0.69
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.03817563)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 113.69 on 2978 degrees of freedom
## AIC: -1270.5
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10126 -0.01853 -0.00224 0.01556 0.52073
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0567912 0.0007071 80.319 <2e-16 ***
## my.x -0.0005702 0.0002609 -2.186 0.0289 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009282716)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7644 on 2978 degrees of freedom
## AIC: -12346
##
## Number of Fisher Scoring iterations: 2

## [1] "days.above.90"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.97151 -0.10028 0.01532 0.11673 0.77768
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.025413 0.003743 6.790 1.35e-11 ***
## my.x 0.004267 0.002887 1.478 0.139
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.03814968)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 113.61 on 2978 degrees of freedom
## AIC: -1272.5
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10374 -0.01870 -0.00214 0.01537 0.52003
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.586e-02 5.843e-04 95.599 <2e-16 ***
## my.x -4.225e-05 4.506e-04 -0.094 0.925
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009297582)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7688 on 2978 degrees of freedom
## AIC: -12341
##
## Number of Fisher Scoring iterations: 2

## [1] "days.above.95"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.97272 -0.09991 0.01516 0.11594 0.77648
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.026617 0.003621 7.351 2.53e-13 ***
## my.x 0.003498 0.004587 0.763 0.446
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.03817022)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 113.67 on 2978 degrees of freedom
## AIC: -1270.9
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10372 -0.01867 -0.00215 0.01539 0.51998
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.583e-02 5.651e-04 98.799 <2e-16 ***
## my.x 7.803e-05 7.159e-04 0.109 0.913
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009297572)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7688 on 2978 degrees of freedom
## AIC: -12341
##
## Number of Fisher Scoring iterations: 2

## [1] "days.above.99th"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.9732 -0.1002 0.0153 0.1161 0.7760
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0279420 0.0049859 5.604 2.28e-08 ***
## my.x -0.0004227 0.0016200 -0.261 0.794
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0381768)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 113.69 on 2978 degrees of freedom
## AIC: -1270.4
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10174 -0.01851 -0.00229 0.01541 0.52092
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0569441 0.0007776 73.235 <2e-16 ***
## my.x -0.0005142 0.0002526 -2.035 0.0419 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009284692)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7650 on 2978 degrees of freedom
## AIC: -12345
##
## Number of Fisher Scoring iterations: 2

## [1] "days.above.99.5th"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.97291 -0.09997 0.01555 0.11553 0.77629
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0281486 0.0045344 6.208 6.12e-10 ***
## my.x -0.0006684 0.0016729 -0.400 0.69
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.03817563)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 113.69 on 2978 degrees of freedom
## AIC: -1270.5
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10126 -0.01853 -0.00224 0.01556 0.52073
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0567912 0.0007071 80.319 <2e-16 ***
## my.x -0.0005702 0.0002609 -2.186 0.0289 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009282716)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7644 on 2978 degrees of freedom
## AIC: -12346
##
## Number of Fisher Scoring iterations: 2

## [1] "mean.temp.quantile"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.98333 -0.09684 0.01291 0.11484 0.79752
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -4.508 0.750 -6.011 2.06e-09 ***
## my.x 4.578 0.757 6.048 1.65e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.03771449)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 112.31 on 2978 degrees of freedom
## AIC: -1306.7
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10124 -0.01828 -0.00213 0.01573 0.51328
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.7888 0.1167 -6.757 1.69e-11 ***
## my.x 0.8525 0.1178 7.236 5.87e-13 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009136979)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7210 on 2978 degrees of freedom
## AIC: -12393
##
## Number of Fisher Scoring iterations: 2

## [1] "max.temp.quantile"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.96822 -0.09832 0.01425 0.11584 0.80617
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -3.5956 0.7459 -4.821 1.50e-06 ***
## my.x 3.6435 0.7502 4.857 1.25e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.03787764)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 112.80 on 2978 degrees of freedom
## AIC: -1293.8
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10612 -0.01848 -0.00188 0.01546 0.51677
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.5001 0.1164 -4.296 1.79e-05 ***
## my.x 0.5592 0.1171 4.776 1.88e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009226938)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7478 on 2978 degrees of freedom
## AIC: -12364
##
## Number of Fisher Scoring iterations: 2

## [1] "min.temp.quantile"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.98857 -0.09841 0.01601 0.11536 0.77765
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2.4016 0.7664 -3.134 0.00174 **
## my.x 2.4614 0.7767 3.169 0.00155 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.03804937)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 113.31 on 2978 degrees of freedom
## AIC: -1280.4
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10237 -0.01863 -0.00219 0.01560 0.51831
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.4482 0.1194 -3.752 0.000179 ***
## my.x 0.5108 0.1211 4.220 2.52e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009242349)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7524 on 2978 degrees of freedom
## AIC: -12359
##
## Number of Fisher Scoring iterations: 2

## [1] "pop100"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.96818 -0.10089 0.01295 0.11616 0.78215
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.886e-02 4.614e-03 4.087 4.49e-05 ***
## my.x 6.653e-09 2.374e-09 2.803 0.0051 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.03807723)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 113.39 on 2978 degrees of freedom
## AIC: -1278.2
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10327 -0.01857 -0.00201 0.01534 0.51744
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.509e-02 7.207e-04 76.442 <2e-16 ***
## my.x 6.096e-10 3.707e-10 1.644 0.1
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009289176)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7663 on 2978 degrees of freedom
## AIC: -12344
##
## Number of Fisher Scoring iterations: 2

## [1] "Ppoverty"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.96073 -0.09956 0.01541 0.11639 0.77997
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.03900 0.01184 3.294 0.000999 ***
## my.x -0.08721 0.08228 -1.060 0.289299
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.03816328)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 113.65 on 2978 degrees of freedom
## AIC: -1271.5
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10650 -0.01845 -0.00205 0.01553 0.52001
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.053171 0.001847 28.785 <2e-16 ***
## my.x 0.019477 0.012838 1.517 0.129
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009290428)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7667 on 2978 degrees of freedom
## AIC: -12344
##
## Number of Fisher Scoring iterations: 2

## [1] "Ppoverty75p"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.96393 -0.09968 0.01573 0.11654 0.78256
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.03969 0.01205 3.295 0.000997 ***
## my.x -0.11167 0.10150 -1.100 0.271308
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.03816216)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 113.65 on 2978 degrees of freedom
## AIC: -1271.5
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10491 -0.01846 -0.00209 0.01542 0.52003
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.05422 0.00188 28.837 <2e-16 ***
## my.x 0.01430 0.01584 0.902 0.367
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009295067)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7681 on 2978 degrees of freedom
## AIC: -12342
##
## Number of Fisher Scoring iterations: 2

## [1] "Purban"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.98203 -0.10026 0.01417 0.11486 0.77640
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.15052 0.06535 -2.303 0.02134 *
## my.x 0.18770 0.06898 2.721 0.00655 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.038083)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 113.41 on 2978 degrees of freedom
## AIC: -1277.7
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10459 -0.01851 -0.00197 0.01537 0.51900
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.03870 0.01021 3.791 0.000153 ***
## my.x 0.01813 0.01077 1.682 0.092589 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.000928878)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7662 on 2978 degrees of freedom
## AIC: -12344
##
## Number of Fisher Scoring iterations: 2

## [1] "P75p"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.97423 -0.10044 0.01471 0.11568 0.78084
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.009905 0.015183 -0.652 0.5142
## my.x 0.670282 0.267750 2.503 0.0124 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0380975)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 113.45 on 2978 degrees of freedom
## AIC: -1276.6
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10391 -0.01843 -0.00204 0.01565 0.51989
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.049525 0.002369 20.906 < 2e-16 ***
## my.x 0.114620 0.041775 2.744 0.00611 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009274165)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7618 on 2978 degrees of freedom
## AIC: -12349
##
## Number of Fisher Scoring iterations: 2

## [1] "pop.density"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.97510 -0.09896 0.01413 0.11688 0.78428
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.017168 0.004324 3.970 7.34e-05 ***
## my.x 11.413581 2.822498 4.044 5.39e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.03796919)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 113.07 on 2978 degrees of freedom
## AIC: -1286.6
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10410 -0.01838 -0.00218 0.01536 0.51705
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0539502 0.0006738 80.064 < 2e-16 ***
## my.x 2.1883872 0.4398516 4.975 6.89e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009220963)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7460 on 2978 degrees of freedom
## AIC: -12366
##
## Number of Fisher Scoring iterations: 2

## [1] "mean.temp.1"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.95266 -0.09587 0.01591 0.11645 0.80225
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.141976 0.027232 5.214 1.98e-07 ***
## my.x -0.001950 0.000458 -4.258 2.13e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0379467)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 113.01 on 2978 degrees of freedom
## AIC: -1288.4
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.09870 -0.01866 -0.00209 0.01565 0.51583
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.408e-02 4.231e-03 19.875 < 2e-16 ***
## my.x -4.791e-04 7.115e-05 -6.733 1.99e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009158206)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7273 on 2978 degrees of freedom
## AIC: -12386
##
## Number of Fisher Scoring iterations: 2

## [1] "mean.summer.temp"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.94901 -0.09863 0.01634 0.11742 0.80527
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.2490199 0.0414484 6.008 2.11e-09 ***
## my.x -0.0030554 0.0005684 -5.376 8.22e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.03781079)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 112.60 on 2978 degrees of freedom
## AIC: -1299.1
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10280 -0.01857 -0.00213 0.01575 0.51700
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.019e-01 6.444e-03 15.814 < 2e-16 ***
## my.x -6.341e-04 8.837e-05 -7.175 9.07e-13 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009139603)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7218 on 2978 degrees of freedom
## AIC: -12392
##
## Number of Fisher Scoring iterations: 2

for (x in xvar2){
print(x)
my.x <-hw[,x]
my.mod1 <- glm(y1~my.x)
print(summary(my.mod1))
#plot(my.x, y1, main = x, xlab = x)
to_plot <- data.frame(my.x, y1, y2)
a <- ggplot(to_plot, aes(x = my.x, y = y1)) + geom_point(alpha = 0.3) + geom_smooth(method = "lm") + xlab(x) + ggtitle(x)
print(a)
my.mod2 <- glm(y2~my.x)
print(summary(my.mod2))
#plot(my.x, y2, main = x, xlab = x)
b <- ggplot(to_plot, aes(x = my.x, y = y2)) + geom_point() + geom_smooth(span = 0.3,method = "lm") + xlab(x) + ggtitle(x)
print(b)
}
## [1] "start.month"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.94929 -0.09803 0.01443 0.11560 0.77208
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.128440 0.029785 4.312 1.67e-05 ***
## my.x -0.013917 0.004058 -3.429 0.000613 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.03802751)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 113.25 on 2978 degrees of freedom
## AIC: -1282.1
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10171 -0.01860 -0.00252 0.01538 0.51916
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0764855 0.0046417 16.48 < 2e-16 ***
## my.x -0.0028332 0.0006325 -4.48 7.76e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009235377)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7503 on 2978 degrees of freedom
## AIC: -12361
##
## Number of Fisher Scoring iterations: 2

## [1] "first.in.season"
##
## Call:
## glm(formula = y1 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.96622 -0.09896 0.01520 0.11558 0.76505
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.020115 0.004563 4.408 1.08e-05 ***
## my.x 0.017936 0.007345 2.442 0.0147 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.03810139)
##
## Null deviance: 113.69 on 2979 degrees of freedom
## Residual deviance: 113.47 on 2978 degrees of freedom
## AIC: -1276.3
##
## Number of Fisher Scoring iterations: 2

##
## Call:
## glm(formula = y2 ~ my.x)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.10236 -0.01829 -0.00224 0.01550 0.52134
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0544712 0.0007116 76.543 < 2e-16 ***
## my.x 0.0035529 0.0011456 3.101 0.00194 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 0.0009267675)
##
## Null deviance: 2.7688 on 2979 degrees of freedom
## Residual deviance: 2.7599 on 2978 degrees of freedom
## AIC: -12351
##
## Number of Fisher Scoring iterations: 2

pairs(xvar1)